package com.example.kotlin.basis

/**
 * Created by xiao_tan on 17/7/23.
 * Loop and Range
 */

fun main(args: Array<String>) {
    var numbs = 1..100  //[1,100] 闭区间

    var result = 0
    for (num in numbs){
        result += num;
    }
    println("结果:${result}")
    println("结果:${numbs.sum()}")


    var numbs1 = 1 until 100; //[1,100)
    println("结果:${numbs1.sum()}")


    var numbs2 = 1 .. 16
    for (numb in numbs2 step 2){
        println(numb)
    }

    val numbs3 = numbs2.reversed()
    for (numb in numbs3){
        println(numb)
    }

    println("总数为:${numbs3.count()}")

}